gdk/wayland: Perform xdg_activation on gdk_window_set_startup_id
authorCarlos Garnacho <carlosg@gnome.org>
Wed, 18 Jan 2023 19:03:01 +0000 (20:03 +0100)
committerCarlos Garnacho <carlosg@gnome.org>
Wed, 25 Jan 2023 10:22:40 +0000 (11:22 +0100)
This call has everything to perform activation as specified by the
xdg_activation protocol, notably a surface to activate as opposed to
gdk_notify_startup_complete().

Make activation happen here, so that the surface gets activated when
its gets a startup ID assigned.

(cherry-picked from commit 5aeabdb3d404579b5cab4fff1642ed116f745a8b)

gdk/wayland/gdkwindow-wayland.c

index 6ba939a73903f9efd3d4319373cb1bde58b53110..041c4d3898d1ac0c6166eaa677041af7499ca4c4 100644 (file)
@@ -4160,6 +4160,27 @@ static void
 gdk_wayland_window_set_startup_id (GdkWindow   *window,
                                    const gchar *startup_id)
 {
+  GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
+  GdkDisplay *display = gdk_window_get_display (window);
+  GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
+  gchar *free_me = NULL;
+
+  if (!startup_id)
+    {
+      free_me = g_steal_pointer (&display_wayland->startup_notification_id);
+      startup_id = free_me;
+    }
+
+#ifdef HAVE_XDG_ACTIVATION
+  if (startup_id)
+    {
+      xdg_activation_v1_activate (display_wayland->xdg_activation,
+                                  startup_id,
+                                 impl->display_server.wl_surface);
+    }
+#endif
+
+  g_free (free_me);
 }
 
 static gboolean